﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace HQPad.Models
{
    public class SkillBonusValueItemModel
    {
        public string Name { get; set; }
        public string Value { get; set; }
        public string Key { get; set; }
    }

    public class SkillBonusValueListModel : List<SkillBonusValueItemModel>
    {
        public string ToJson()
        {
            StringBuilder json = new StringBuilder("[");

            bool first = true;

            foreach (SkillBonusValueItemModel item in this)
            {
                if (first)
                    first = false;
                else
                    json.Append(", ");

                json.AppendFormat("{{key: '{0}', name: '{1}', value: '{2}'}}", item.Key, HttpUtility.HtmlEncode(item.Name), item.Value);
            }

            json.Append("]");

            return json.ToString();
        }
    }
}